'use strict';


// Declare app level module which depends on filters, and services
var app = angular.module('myApp', [
    'ngRoute',
    'myApp.services',
    'myApp.filters',
    'myApp.directives',
    'myApp.controllersMain',
    'myApp.controllersGame',
    'subscriberFastclick',
    'subscriberBackbutton',
    'subscriberAdmob'
]);

app.config(['$routeProvider', function ($routeProvider) {
        $routeProvider.when('/main', {templateUrl: 'partials/main.html', controller: 'MainCtrl'});
        $routeProvider.when('/main/about', {templateUrl: 'partials/main_about.html', controller: 'MainAboutCtrl'});
        $routeProvider.when('/main/setting', {templateUrl: 'partials/main_setting.html', controller: 'MainSettingCtrl'});
        $routeProvider.when('/main/stats', {templateUrl: 'partials/main_stats.html', controller: 'MainStatsCtrl'});
        $routeProvider.when('/game/single', {templateUrl: 'partials/game.html', controller: 'GameSingleCtrl'});
        $routeProvider.when('/game/multi', {templateUrl: 'partials/game.html', controller: 'GameMultiCtrl'});
        $routeProvider.when('/game/quit', {templateUrl: 'partials/game_quit.html', controller: 'GameQuitCtrl'});
        $routeProvider.otherwise({redirectTo: '/main'});
    }]);

app.run([
    function ($location, $rootScope, serviceGame, servicePopupFunc) {

        var event = document.createEvent('Event');
        event.initEvent('appready', true, true);
        document.dispatchEvent(event);

        /**
         * turn off splashscreen
         */
        setTimeout(function () {
            if (typeof navigator.splashscreen !== 'undefined') {
                navigator.splashscreen.hide();
            }
        }, 1000);

    }
]);
